#include <bits/stdc++.h>
using namespace std;
int T,y,q;
double e,f,g;
int main(void){
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%lf%lf%lf",&y,&q,&e,&f,&g);
        double a=(y+y*e/100*q/365)*(1+g/100);
        double b=y+y*f/100*(q+365)/365;
        printf("%.1lf\n%.1lf\n",a,b);
    }
    return 0;
}